//
//  ITSocketError.swift
//  QuicDemo
//
//  Created by ellzu gu on 2021/6/29.
//

import Foundation

extension EZSocket {
    
    public static var ErrorDomain : String = "EZSocket";
    /// Socket的错误类型
    public enum ErrorCode : Int {
        case None = 0; /// 没有错误
        case StatusError = 1; /// 调用顺序出问题
        case DNSError = 2; /// DNS解析失败
        case InterfaceError = 3; /// 指定网卡错误
        case SystemError = 4; /// 调用系统接口出错
        case ConnectError = 5; /// 链接错误
        case TimeoutError = 6; /// 超时
        case DisconnectError = 7; /// 已断开链接
    }
    
    func error(code : EZSocket.ErrorCode, sub : EZError? = nil) -> EZError {
        return EZError.init(EZSocket.ErrorDomain, code.rawValue, message: nil, subError: sub);
    }
    
    func error(systemCode : Int32) -> EZError {
        return EZError.init("System", Int(systemCode));
    }
    
}
